package com.huatai.manage.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName ComUtil
 * @Description TODO
 * @Author luoxc
 * @Date 2023/3/20 13:33
 * @Version 1.0
 */
public class ComUtil {

	/**
	 * 生成uuid
	 * @return
	 */
	public static String getUUID() {
		return IdUtil.simpleUUID().toUpperCase();
	}


	/**
	 * List对象转List对象
	 *
	 * @param list
	 * @return
	 */
	public static <T> List<T> toList(List<?> list, Class<T> cla) {
		return list.stream().map(i -> BeanUtil.toBean(i, cla)).collect(Collectors.toList());
	}

	/**
	 * 校验集合是否为空
	 * @param list
	 * @return
	 * @param <T>
	 */
	public static <T> boolean listIsNotEmpty(List<T> list) {
		return null != list && list.size() != 0;
	}

	/**
	 * 校验集合是否为空
	 * @param list
	 * @return
	 * @param <T>
	 */
	public static <T> boolean listIsEmpty(List<T> list) {
		return null == list || list.size() == 0;
	}


}
